<#include "header.htm"/>
<#assign preview = preview?default(false)/>
<#assign logModeration = moderationLoggingEnabled && isEdit?default(false) && isModerator && user.id != post.userId/>
<#assign allowPoll = setType?default(true) && canCreatePolls?default(false)/>

<script type="text/javascript">
var CONTEXTPATH = "${contextPath}";
var SERVLET_EXTENSION  = "${extension}";
</script>

<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/tabs.css?${startupTime} );</style>
<#--
<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/SyntaxHighlighter.css?${startupTime} );</style>
-->
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/jquery.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/post.js?${startupTime}"></script>

<script charset="utf-8" type="text/javascript" src="${contextPath}/templates/${templateName}/textEditor_new/kindeditor352.js?${startupTime}"></script>
<script type="text/javascript">
<#include "js/utils.js"/>
<#include "js/attachments.js"/>
</script>

		<script>
		KE.show({
			id : 'message',
			newlineTag : 'br',
				imageUploadJson : '../../../textEditor_new/jsp/upload_json.jsp',
				afterSetData : function(id) {
			var wordCount=KE.count(id,'text');
			KE.$('word_count').innerHTML = ${postMaxLength}-wordCount;
			if(wordCount>${postMaxLength}) alert("您输入的文字过多!");
		},
		  resizeMode : 1,
		  autoSetDataMode:true,
		  shadowMode : false,
		  allowPreviewEmoticons : true	,
			items : [
			 		 'fullscreen', 'undo', 'redo', 'cut', 'copy', 'paste',
			 		'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
			 		'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
			 		'superscript', '|', 'selectall', '-',
			 		'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
			 		'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
			 		'flash', 'media', 'advtable', 'hr', 'emoticons', 'link', 'unlink', '|', 'about'
			 	]	
		});
		</script>

<#--
<script type="text/javascript">

     KE.show({
      id : 'message',
	imageUploadJson : '../../../textEditor_new/jsp/upload_json.jsp',
 	allowFileManager : false,

		afterSetData : function(id) {
			var wordCount=KE.count(id,'text');
			KE.$('word_count').innerHTML = ${postMaxLength}-wordCount;
			if(wordCount>${postMaxLength}) alert("您输入的文字过多!");
		},

	  resizeMode : 1,
	  autoSetDataMode:true,
	  shadowMode : false,
	  allowPreviewEmoticons : true,
 
      items :  [
                  
  'emoticons', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold',
  'italic', 'underline', 'strikethrough', 'title','selectall', 'image',
  'flash', 'media', 'table','wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript',  'link', 'unlink', 
                  'hr','about'
            ]
            
       });
 </script>
 -->
 
<script type="text/javascript">
function newCaptcha()
{
	document.getElementById("captcha_img").src = "${contextPath}/jforum${extension}?module=captcha&action=generate&timestamp=" + new Date().getTime();
}

function validatePostForm()
{  
	f=document.getElementById('post');
	<#if setType?default(true)>
	if (f.subject.value == "") {
		alert("${I18n.getMessage("PostForm.subjectEmpty")}");
		f.subject.focus();
		
		return false;
	}
	</#if>
   
	if(f.forumSelect!=null){
     if(f.forumSelect.value==0){
         alert("请选择版面!!!!!!");
         return false;
         }
	 }
	if (KE.util.isEmpty('message')) {
		alert("${I18n.getMessage("PostForm.textEmpty")}");
		f.message.focus();
		
		return false;
	}
    if(KE.count('message','text')>${postMaxLength}){
        alert("您输入的文字过多!");
        f.message.focus();
        return false
        }
	<#if !forum?exists>
	if (f.toUsername.value == "") {
		alert("${I18n.getMessage("PrivateMessage.toUserIsEmpy")}");
		f.toUsername.focus();

		return false;
	}
	</#if>

	<#if logModeration>
	if (f.log_description.value == "") {
		alert("${I18n.getMessage("ModerationLog.reasonIsEmpty")}");
		f.log_description.focus();

		return false;
	}
	</#if>
	
	$("#icon_saving").css("display", "inline");
	$("#btnPreview").attr("disabled", "disabled");
	$("#btnSubmit").attr("disabled", "disabled").val("${I18n.getMessage("PostForm.saving")}...");

	f.submit();
	return true;
}

function openFindUserWindow()
{
	var w = window.open("${JForumContext.encodeURL("/pm/findUser")}", "_findUser", "height=250,resizable=yes,width=400");
	w.focus();
}

</script>

<#assign preview = preview?exists && preview/>
<#assign isNewPost = isNewPost?exists && isNewPost/>
<#assign isEdit = isEdit?if_exists/>
<#assign isNewTopic = (!topic?exists || topic.id == -1)/>
<#assign attachmentsEnabled = attachmentsEnabled?exists && attachmentsEnabled/>

<#if !maxAttachments?exists>
	<#assign maxAttachments = 0/>
</#if>

<#assign signatureChecked = "checked=\"checked\""/>
<#assign repliesChecked = "checked=\"checked\""/>

<#if isNewPost && !preview && !post?exists>
<#if !user.getAttachSignatureEnabled()><#assign signatureChecked = ""/></#if>
<#elseif post?exists>
<#if !post.isSignatureEnabled()><#assign signatureChecked = ""/></#if>
</#if>

<#if !user.isNotifyOnMessagesEnabled()><#assign repliesChecked = ""/></#if>

<form action="${JForumContext.encodeURL("/jforum")}" method="post" enctype="multipart/form-data" name="post" id="post" >
<input type="hidden" name="action" value="${action}" />
<input type="hidden" name="module" value="${moduleName}" />
<input type="hidden" name="preview" value="0"/>
<#if ask?exists>
<input type="hidden" name="ask" value="${ask}"/>
</#if>

<#if forum?exists><input type="hidden" name="forum_id" id="forum_id" value="${forum.id}" />
   <#if forum.id==0>
     <input type="hidden" name="fromAll" id="fromAll" value="0"/>
   </#if>
</#if>
<input type="hidden" name="start" value="${start?default("")}" />
<#if isEdit><input type="hidden" name="post_id" value="${post.id}" /></#if>
<#if !isNewTopic><input type="hidden" name="topic_id" value="${topic.id}" /></#if>

<table style="margin-top:10px;"  cellspacing="0" cellpadding="1" width="100%" align="center" border="0">
	<tr>
		<td class="bodyline">

			<table cellspacing="0" cellpadding="1" width="100%" align="center" border="0">
				<tr>
					<td align="left">
						<span class="nav">
							<a class="nav" href="${JForumContext.encodeURL("/forums/list")}">${I18n.getMessage("ForumListing.forumIndex")}</a>&raquo;

					       <#if forum?exists>
							
						      <#if forum.id==0>
            			          <a class="nav" href="${JForumContext.encodeURL("/allTopics/list")}">${forum.name} </a>  
           			          <#else>
           			              <a class="nav" href="${JForumContext.encodeURL("/forums/show/${forum.id}")}">${forum.name} </a>
           			          </#if>
                           </#if>
						</span>
					</td>
				</tr>
			</table>
		
			<table class="forumline" cellspacing="0" cellpadding="1" width="100%" border="0">
				<tr>
					<th class="thhead" colspan="2" height="25">
						<b>
						<#if forum?exists>
							<#if (topic?exists && topic.id > -1)>
							    <#if isEdit>
							    	${I18n.getMessage("PostForm.edit")} "${topic.title?html}"
							    <#else>
									${I18n.getMessage("PostForm.reply")} "${topic.title?html}"
								</#if>
							<#else>
								${I18n.getMessage("PostForm.title")}
							</#if>
						<#else>
							<#if pmReply?default(false)>
								${I18n.getMessage("PrivateMessage.reply")}
							<#else>
								${I18n.getMessage("PrivateMessage.title")}
							</#if>
						</#if>
						</b>
					</th>
				</tr>

				<#if !forum?exists>
					<tr>
						<td class="row1" width="17%" nowrap="nowrap"><span class="gen"><b>${I18n.getMessage("PrivateMessage.user")}</b></span></td>
						<td class="row2" >
							<#if pmRecipient?exists>
								<#assign toUsername = toUsername/>
								<#assign toUserId = toUserId/>
								<#elseif preview>
								<#assign toUsername = pm.toUser.username/>
								<#assign toUserId = pm.toUser.id/>
								<#elseif quote?default("") == "true" || pmReply?default(false)>
								<#assign toUsername = pm.fromUser.username/>
								<#assign toUserId = pm.fromUser.id/>
							<#else>
								<#assign toUsername = ""/>
								<#assign toUserId = ""/>
							</#if>

							<input type="text" class="post" size="25" name="toUsername" value="${toUsername}"/>&nbsp;
							<input type="button" value="${I18n.getMessage("PrivateMessage.findUser")}" name="findUser" class="liteoption" onclick="openFindUserWindow(); return false;" />
							<input type="hidden" name="toUserId" value="${toUserId}" />
						</td>
					</tr>
					
					
				</#if>
				
				
				

				<#if errorMessage?exists>
					<tr>
						<td colspan="2" align="center"><span class="gen"><font color="#ff0000"><b>${errorMessage}</b></font></span></td>
					</tr>
				</#if>

              <#if forum?exists && isNewTopic >
					<tr>
						<td class="row1" width="17%" nowrap="nowrap"><span class="gen"><b>选择版面</b></span></td>
						<td class="row2" >
							<select name="forumSelect" id="forumSelect" onchange="if(this.options[this.selectedIndex].value != 0){ 
							        document.getElementById('forum_id').value=this.options[this.selectedIndex].value
							         ;}">
					 		        <option value="0" <#if forum?exists>selected="true"</#if>>请选择版面...</option>
                            <#list allCategories as category>
                               <optgroup label="${category.name}">
                                 <#list category.getForums() as forums> 
					                <option value="${forums.id}" <#if   forum.id==forums.id>selected="true"</#if>>${forums.name}</option>
					 	         </#list>
                               </optgroup>

                             </#list>
	                         </select>
						</td>
					</tr>			
			  </#if>
			  
               
			    <#if !isReply?exists >
				<tr>
					<td class="row1" width="17%" nowrap="nowrap"><span class="gen"><b>${I18n.getMessage("PostForm.subject")}</b></span></td>
					<#if post?exists >
						<#assign subject = post.subject?default("")?html/>
					<#elseif pmReply?default(false)>
						<#assign subject = pm.post.subject?html/>
					<#elseif topic?exists>
						<#assign subject = I18n.getMessage("Message.replyPrefix")/>
					<#elseif ask?exists>
					    <#assign subject="[?] "/>
					</#if>
					<td class="row2" >
						<span class="gen">
							<input class="subject" type="text" tabindex="2" maxlength="80" name="subject" value="${subject?default("")}" /> 
						</span>
					</td>
				</tr>
                </#if>
                
                
				<tr>
					<!-- Smilies -->
					<td class="row1" valign="top" width="170" >
					 <span style="color:red;">请按照论坛规则发帖,不要发敏感贴,谢谢合作</span>
				    </td>
                
					<!--  , textarea -->
					<td class="row2" valign="top">
					
						<div class="gen">
							<table cellspacing="0" cellpadding="2" border="0" width="100%">
		
								<!-- Textarea -->
								<tr> 
									<td valign="top">						
										<textarea style="overflow-x:hidden;" class="message" id="message" name="message"  tabindex="3"  rows="18"  cols="35"    onkeyup="storeCaret(this);" onclick="storeCaret(this);" onselect="storeCaret(this);">
						                <#if post?exists>	
                                         <#if quote?exists>
                                     <fieldset style="border:#176eac 2px solid;font-size:12px;font-size-adjust:none;line-height:19px;margin:10px;overflow-x:hidden;padding:10px;width:620px;">
                                     <legend style="font-size:14px;font-weight: bold;">引用自 ${floor_number?default("")}楼 ${quoteUser} 的回复:</legend>                 
                                               ${post.text?html}  
                                     </fieldset>        
                                         <#else>
                                             ${post.text?html}
                                          </#if>
                                         </#if>
                                         
									    </textarea> 
									    
									</td>
								</tr>

							</table>

						</div> 
						
					</td>
				</tr>

				<!-- Options -->
				<tr>
					<td class="row1" nowrap="nowrap" width="17%">&nbsp;</td>
					<td class="row2">
						<div id="tabs10">
							<ul>
							      <li target="postOptions" class="current"><a href="javascript:void(0);" onClick="activateTab('postOptions', this);"><span>  选项  </span></a></li>

								<#if allowPoll>
									<li target="postPoll"><a href="javascript:void(0);" onClick="activateTab('postPoll', this);"><span>投票</span></a></li>
								</#if>
 								<#if attachmentsEnabled>
								    <li target="postAttachments"><a href="javascript:void(0);" onClick="activateTab('postAttachments', this);"><span>  附件  </span></a></li>
								</#if>
 							
								<font color="red"  ><h4>您还可以输入 <span id="word_count">${postMaxLength}</span> 个文字。</h4></font>
	 					    </ul>
						</div>

						<!-- Post Options -->
						<div id="postOptions" class="postTabContents">
							     
								<#include "post_options_tab.htm"/>
							      
						</div>

						<!-- Poll tab -->
						<#if allowPoll>
							<div id="postPoll" class="postTabContents" style="display: none;">
								  
									<#include "post_poll_tab.htm"/>
								  
							</div>
						</#if>

						<!-- Attachments tab -->
						<#if attachmentsEnabled || attachments?exists>
							<div id="postAttachments" class="postTabContents" style="display: none; ">
								 
									<#include "post_attachments_tab.htm"/>
								 
							</div>
						</#if>
					</td>
				</tr>

				<#if needCaptcha?default(false)>
					<tr>
						<td class="row1" valign="middle"><span class="gensmall"><b>${I18n.getMessage("User.captchaResponse")}:</b></span></td>
						<td class="row2">
							<input type="text" class="post" style="width: 100px; font-weight: bold;" maxlength="25" size="25" name="captcha_anwser" /> 
							 <a href="#newCaptcha" onClick="newCaptcha()"><img src="${JForumContext.encodeURL("/captcha/generate/${timestamp}")}" border="0" align="middle" id="captcha_img" alt="Captcha unavailable" /></a>
							<br />
							<span class="gensmall">${I18n.getMessage("User.hardCaptchaPart1")} <a href="#newCaptcha" onClick="newCaptcha()"><b>${I18n.getMessage("User.hardCaptchaPart2")}</b></a></span>
						</td>
					</tr>
				</#if>

				<#if logModeration>
					<tr>
						<td align="center" class="row1 gen"><b>${I18n.getMessage("ModerationLog.moderationLog")}</b></td>
						<td class="row2 genmed">${I18n.getMessage("ModerationLog.changeReason")} <input type="text" name="log_description" size="50" /><input type="hidden" name="log_type" value="2" /></td>
					</tr>
				</#if>

				<#if error?exists>
					<tr>
						<td class="row1">&nbsp;</td>
						<td class="row2"><span class="gen"><font color="red"><b>${error}</b></font></span></td>
					</tr>
				</#if>
				
				<tr>
					<td align="center" height="28" colspan="2" class="catbottom">
<#--					<input class="mainoption" id="btnPreview" tabindex="5" type="button" value="${I18n.getMessage("PostForm.preview")}" onclick="previewMessages('message');" />&nbsp;
-->						<input class="mainoption" id="btnSubmit" accesskey="s" tabindex="6" type="button" value="${I18n.getMessage("PostForm.submit")}" name="post" onclick="validatePostForm()"/>
						<img src="${contextPath}/images/transp.gif" id="icon_saving">
					</td>
				</tr>
			</table>
		</td>
	</tr>

<#--
	<#if ((topic?exists && topic.id > 0) || pmReply?default(false))>
	<tr>
	<td colspan="2">
		<table border="0" cellpadding="3" cellspacing="0" width="100%" class="forumline">
			<tr>
				<th class="cathead" height="28" align="center"><b><span class="cattitle">${I18n.getMessage("PostShow.topicReview")}</span></b></th>
			</tr>
	
			<tr>
				<td class="row1">
					<#if pmReply?default(false)>
						<iframe width="100%" height="300" frameborder="0" src="${JForumContext.encodeURL("/jforum${extension}?module=pm&amp;action=review&amp;id=${pm.id}", "")}" ></iframe>
					<#else>
						<iframe width="100%" height="300" frameborder="0" src="${JForumContext.encodeURL("/posts/review/${start}/${topic.id}")}" ></iframe>
					</#if>
				</td>
			</tr>
			
		</table>
	</td>
	</tr>
	</#if>
-->
</table>
<script type="text/javascript">
<#if attachments?exists>
	ignoreStart = true;
	editAttachments();
</#if>
<#if preview>document.location = "#preview";</#if>

</script>

</form>

<#include "bottom.htm"/>